import Vue from 'vue'
import Router from 'vue-router'
import Layout from './layout'
import Index from './views/index'

Vue.use(Router)

export default new Router({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      component: Layout,
      meta: {
        title: '首页'
      },
      children: [
        {
          path: '',
          name: 'index',
          meta: {
            title: '首页'
          },
          component: Index
        },
        {
          path: 'system',
          name: 'System',
          meta: {
            title: '系统配置'
          },
          component: () => import('./views/system')
        },
        {
          path: 'user',
          name: 'User',
          meta: {
            title: '用户管理'
          },
          component: () => import('./views/users')
        },
        {
          path: 'user/logs',
          name: 'UserLogs',
          meta: {
            title: '财务日志'
          },
          component: () => import('./views/users/logs')
        },
        {
          path: 'article',
          name: 'Article',
          meta: {
            title: '文章管理'
          },
          component: () => import('./views/article')
        },
        {
          path: 'article/create',
          name: 'ArticleCreate',
          meta: {
            title: '发布新文章'
          },
          component: () => import('./views/article/create')
        },
        {
          path: '401',
          name: '401',
          component: () =>import('./views/common/401')
        }
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: () =>import('./views/login')
    },
    {
      path: '*',
      name: '404',
      component: () =>import('./views/common/404')
    }
  ]
})
